/**
 * author:Administrator
 * date:2016/3/16
 * desc:TODO
 */
"use strict";

let RawQuery = require('./_RawQuery.js');
class TicketQuery extends RawQuery {
  constructor() {
    super();
  }

  * findByCustomer(customerId, pageIndex, pageSize) {
    let sql = "select from `couponLog` " +
      " where customerId='%customerId' " +
      " limit %start,%end " +
      " order by `createdAt` desc";

    let offset = this.offset(pageIndex, pageSize);
    sql = sql.replace('%customerId', customerId)
      .replace('%start', offset.start)
      .replace('%end', offset.end);
    return yield this.query(sql);
  }

}

module.exports = new TicketQuery();